import * as api from '../../api/index'
import { Notification } from 'element-ui';
const state={
	   data:[],//列表数据
	   query:{},
	   page:{total:0},//分页数据
	   list_loading:false//加载状态
}

const actions = {
	getData({commit},params){
		if(!params) params={};
		commit('update',{type:'list_loading',data:true});
		api.log.getData(params,res=>{
			commit('update',{type:'list_loading',data:false});
				if(res.status==1) {
					commit('update',{type:'query',data:params});//更新查询数据
					commit('update',{type:'data',data:res.data});//更新列表数据
					commit('update',{type:'page',data:res.page});//更新分页数据
				}
			    else Notification(res);
			});
	}
}

const mutations = {
    update(state,p){//更新数据状态
    	state[p.type] = p.data;
    	},
	del(state,str){//删除数据
		eval(str);
	}
}

export default {
  namespaced: true,
  state,
  actions,
  mutations
}
